package com.hopes.bizz.poll.monitor.vo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.hopes.bizz.poll.common.constant.enums.PollModDictEnum;
import com.hopes.bizz.poll.common.constant.enums.PollSysDictEnum;
import com.hopes.bizz.poll.monitor.entity.PollMonitorFactorEntity;
import com.hopes.boss.admin.api.resolver.DictResolver;
import com.hopes.boss.admin.api.resolver.enums.AdminDictEnum;
import com.hopes.boss.admin.api.resolver.enums.SysDictEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author yumr
 * @ProjectName bizz
 * @Description 监控点信息
 * @time 2023/5/23 17:46
 */
@Data
@EqualsAndHashCode
public class PollMonitorSiteVo implements Serializable {

    private static final long serialVersionUID = -3340185713613922115L;

    /**
     * id
     */
    @TableId(type = IdType.ASSIGN_ID)
    @Schema(description="id")
    private Long id;

    /**
     * 所属乡镇
     */
    @Schema(description="所属乡镇")
    private Long townId;

    /**
     * 所属企业
     */
    @Schema(description="所属企业")
    private Long orgId;

    /**
     * 监控类型
     */
    @Schema(description="监控类型")
    private String monitorType;

    /**
     * 监控点名称
     */
    @Schema(description="监控点名称")
    private String name;

    /**
     * 监控点编号
     */
    @Schema(description="监控点编号")
    private String code;

    /**
     * 是否使用
     */
    @Schema(description="是否使用")
    private Boolean isUse;


    /**
     * 监控点视频
     */
    @Schema(description="监控点视频")
    private String videoIds;

    /**
     * 是否关联视频
     */
    @Schema(description="是否关联视频")
    private Boolean videoAssociation;

    /**
     * AQI站点标记
     */
    @Schema(description="AQI站点标记")
    private Boolean aqiFlag;

    /**
     * 监控点位置
     */
    @Schema(description="监控点位置")
    private String monitorLocation;

    /**
     * 定位
     */
    @Schema(description="定位")
    private String gisLocation;

    /**
     * 考核标准
     */
    @Schema(description="考核标准")
    private String assessmentCriteria;

    /**
     * 目标水质
     */
    @Schema(description="目标水质")
    private String waterQuality;

    @Schema(description = "监测因子")
    private List<PollMonitorFactorEntity> pollMonitorFactorEntityList;


    public String getOrgIdStr() {
        return DictResolver.getItemLabelByValue(AdminDictEnum.sys_company, this.orgId);
    }

    public String getMonitorTypeStr() {
        return DictResolver.getItemLabelByValue(PollModDictEnum.site_type, this.getMonitorType());
    }
    public String getIsUseStr() {
        return DictResolver.getItemLabelByValue(SysDictEnum.yes_no_type, this.isUse);
    }

    public String getAqiFlagStr() {
        return DictResolver.getItemLabelByValue(SysDictEnum.yes_no_type, this.getAqiFlag());
    }

    public String getMonitorFactorNamesStr() {
        return pollMonitorFactorEntityList.stream().map(PollMonitorFactorEntity::getFactorIdStr).collect(Collectors.joining(","));
    }

    public String getAssessmentCriteriaStr() {
        return DictResolver.getItemLabelByValue(PollSysDictEnum.water_assessment_criteria, this.assessmentCriteria);
    }

    public String getWaterQualityStr() {
        return DictResolver.getItemLabelByValue(PollSysDictEnum.water_quality, this.waterQuality);
    }
}
